package com.njupt.towersinfos.controller;


import com.njupt.towersinfos.domain.Tower;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/tw")
@CrossOrigin("*")
public class TowerCtrl {
    @RequestMapping("/findTower")
    public List<Tower> findTower(){
        List<Tower> tws=new ArrayList<>();
        tws.add(Tower.builder().towerid("tj111").company("中铁").build());
        tws.add(Tower.builder().towerid("tj112").company("中铁").build());
        return tws;
    }
    @RequestMapping("/insertTower")
    public String insertTower(Tower tower){
        return "{\"towerreg\":\"success\"}";
    }
    @RequestMapping("/modTower")
    public String modTower(Tower tower){
        return "{\"towermod\":\"success\"}";
    }
    @RequestMapping("/delTower/{towerid}")
    //@PathVariable 从URL模板变量中捕获值的注解，{towerid}的值将被捕获并传递给该方法的towerid参数。
    public String delTower(@PathVariable("towerid")String towerid){
        return "{\"towerdestory\":\"success\"}";
    }



}
